<template>
    <div class="maxContainer content">
        <div class="formContainer">
            <el-form :inline="true" :model="extensionDataRecordParam" >
                <el-checkbox-group>
                    <el-form-item label="用户ID">
                        <el-input v-model="extensionDataRecordParam.userId" placeholder="用户ID"></el-input>
                    </el-form-item>
                    <el-form-item label="用户邮箱">
                        <el-input v-model="extensionDataRecordParam.email" placeholder="用户邮箱"></el-input>
                    </el-form-item>
                    <el-form-item label="用户昵称">
                        <el-input v-model="extensionDataRecordParam.nickname" placeholder="用户昵称"></el-input>
                    </el-form-item>
                    <el-form-item label="推广码">
                        <el-input v-model="extensionDataRecordParam.code" placeholder="推广码"></el-input>
                    </el-form-item>
                    <el-form-item label="用户IP">
                        <el-input v-model="extensionDataRecordParam.ip" placeholder="用户IP"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button @click="defaultSearch()">搜索</el-button>
                    </el-form-item>
                </el-checkbox-group>
            </el-form>
        </div>
        <div class="min tableData">
            <el-table :data="tableDataRecord" border style="width: 100%">
                <el-table-column prop="userId" label="用户ID" ></el-table-column>
                <el-table-column prop="email" label="用户邮箱" ></el-table-column>
                <el-table-column prop="nickname" label="用户昵称" > </el-table-column>
                <el-table-column prop="ip" label="IP" > </el-table-column>
                <el-table-column prop="createdAt" label="时间" > </el-table-column>
            </el-table>
            <el-pagination
            background
            layout="prev, pager, next"
            :page-count="extensionDataRecordParam.pageCount"
            @current-change="currentPageChangeRecord">
        </el-pagination>
        </div>
    </div>
</template>

<script>
import api from '../../../api/Basicpath/index'
export default {
    data() {
      return {
        extensionDataRecordParam: {
          userId: '',
          email: '',
          nickname: '',
          ip: '',
          currentPage:1,
          pageSize:3,
          pageCount:10
        },
        tableDataRecord: []
      }
    },
    methods: {
        currentPageChangeRecord(currentPage){
            this.extensionDataRecordParam.currentPage = currentPage;
            this.onSearch();
        },
        currentMonthLast(){
            var date=new Date();
            var currentMonth=date.getMonth();
            var nextMonth=++currentMonth;
            var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1);
            var oneDay=1000*60*60*24;
            return new Date(nextMonthFirstDay-oneDay);
        },
        defaultSearch(){
            this.extensionDataRecordParam.currentPage = 1;
            this.extensionDataRecordParam.pageCount = 1;
            this.onSearch();
        },
        onSearch() {
            this.$axios.get(`${api}/gamemall/visitRecord/list`,this.extensionDataRecordParam)
				.then( res => {
				if(res.code === 200){                    
                    console.log(res.obj.list);
                    if(res.obj==null || res.obj.list==null || res.obj.list.length === 0){
                        this.extensionDataRecordParam.currentPage = 1;
                        this.extensionDataRecordParam.pageCount = 0;
                        this.tableDataRecord =[];
                    }else{
                        this.tableDataRecord = res.obj.list;
					    this.extensionDataRecordParam.pageCount = res.obj.pages;
                    }
				}else if(res.code === 500){
					// this.$message({
					// message: res.msg || '请求数据失败',
					// type: 'warning'
					// })
				}
				})
				.catch( err =>{
				// this.$message({
				// 	message: err.msg || '请求数据失败',
				// 	type: 'warning'
				// 	})
                }
            );
        },
        currentPageChange(currentPage) {
            this.extensionDataRecordParam.currentPage = currentPage;
            this.onSearch();
        }
    },
    created:function (){
      this.onSearch();
    }
};
</script>
<style scoped>
    .content {
        width: 99%;
        height: 99%;
        display: flex;
        flex-direction: column;
        /* justify-content: center; */
        padding-top: 2%;
        margin-left: 0.5%;
        border: 1px solid #EBEEF5;
        background-color: #FFF;
        border-radius: 0.325rem;
        font-family: Avenir,Helvetica,Arial,sans-serif;
    }
    .el-form{
        text-align: left;
        margin-left: 2%;
    }
</style>